#include "cardviewobject.h"
#include <QDebug>
#include <QGraphicsSceneContextMenuEvent>


CardViewObject::CardViewObject(AbstractCard * card)
    : m_Card(card)
{
    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    cardRect = QRect(-10, -20, 60, 80);
}

void CardViewObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
           QWidget *)
{
    painter->setPen(Qt::black);
    painter->setBrush(Qt::white);    
    painter->drawRect(cardRect);
    if (m_Card != 0)
        painter->drawText(cardRect.adjusted(5, 5, -5, -5), m_Card->property("CardName").toString());
    else
    {
        painter->setPen(Qt::red);
        painter->drawLine(cardRect.topLeft(), cardRect.bottomRight());
        painter->drawLine(cardRect.topRight(), cardRect.bottomLeft());
    }
}

QRectF CardViewObject::boundingRect() const
{    
    return cardRect.adjusted(-5, -5, 5, 5);
}

QPainterPath CardViewObject::shape() const
{
    QPainterPath path;
    path.addRect(cardRect);
    return path;
}

CardViewObjectData *CardViewObject::getViewObjectInformation()
{
    return NULL;
}
